home *** CD-ROM | disk | FTP | other *** search
/ Revista CD Expert 37 / CD Expert nº 37.iso / LastCall / lastcall.exe / stuff / recipe.dxr / 00001_Window utils.ls next >
Encoding:
Text File  |  2000-03-23  |  9.1 KB  |  297 lines

  1. global gRecipeWindow, gOldRecipeRect
  2.  
  3. on closeWindow
  4. end
  5.  
  6. on openWindow
  7.   global gIngredients, gRecipes, gUserTips, gScroller, gRecipeNameSprite, gQuickWidth
  8.   gRecipeNameSprite = sprite(21)
  9.   gScroller = sprite(22)
  10.   if voidp(gRecipes) then
  11.     gRecipes = getOldRecipesDB()
  12.   end if
  13.   if voidp(gIngredients) then
  14.     gIngredients = getOldIngredientsDB()
  15.   end if
  16.   if voidp(gUserTips) then
  17.     gUserTips = getOldUserTipsDB()
  18.   end if
  19.   if (the activeWindow).rect.width = gQuickWidth then
  20.     go("QuickView")
  21.   else
  22.     refreshRecipeWindow()
  23.   end if
  24.   resetCursor()
  25. end
  26.  
  27. on checkElapsedTime
  28. end
  29.  
  30. on startMovie
  31.   global gFullWidth, gQuickWidth, gFullHeight, gSecretHelp
  32.   if FileExists(gSecretHelp) and not authoring() then
  33.     castLib("help_graphics").fileName = gSecretHelp
  34.   end if
  35.   gFullWidth = 321
  36.   gQuickWidth = 148
  37.   gFullHeight = 237
  38.   if voidp(gRecipeWindow) then
  39.     gRecipeWindow = the activeWindow
  40.   end if
  41.   openWindow()
  42.   set the mouseDownScript to "resetFocusMouseDown"
  43.   set the mouseUpScript to "resetFocusMouseUp"
  44. end
  45.  
  46. on stopMovie
  47. end
  48.  
  49. on clearAllText
  50.   debugAlert("This should not be called during a projector")
  51.   repeat with patronNum = 1 to 3
  52.     setRecipePatronName(patronNum, "No Patron")
  53.     setRecipeDrinkName(patronNum, "No Drink")
  54.     temp = "Please refresh the Recipe Book window to see the correct recipe description for Patron" && patronNum
  55.     setRecipeFullText(patronNum, temp)
  56.   end repeat
  57.   setRecipeQuickText(findActiveRecipeSlot(), "Please refresh the Recipe Book window to see the updated QuickView ingredient list.")
  58. end
  59.  
  60. on adjustWindowWidth diffH, diffV
  61.   if not (diffH or diffV) then
  62.     exit
  63.   end if
  64.   newRect = duplicate((the activeWindow).rect)
  65.   if diffH then
  66.     newRect.right = (the activeWindow).rect.right - diffH
  67.   end if
  68.   if diffV then
  69.     newRect.bottom = (the activeWindow).rect.bottom - diffV
  70.   end if
  71.   (the activeWindow).rect = newRect
  72. end
  73.  
  74. on fullSize
  75.   global gFullWidth, gFullHeight
  76.   adjustWindowWidth((the activeWindow).rect.width - gFullWidth, (the activeWindow).rect.height - gFullHeight)
  77. end
  78.  
  79. on fullView
  80.   global gLastCurrent
  81.   slotNum = gLastCurrent
  82.   if not isVisible(the activeWindow) then
  83.     exit
  84.   end if
  85.   recipeID = currentRecipe()
  86.   if recipeID > 0 then
  87.     recipeInfo = createRecipe(recipeID)
  88.     fullText = recipeInfo[#text]
  89.     drinkName = recipeInfo[#name]
  90.   else
  91.     fullText = noRecipeText(slotNum)
  92.     quickText = noRecipeText(slotNum, 1)
  93.     drinkName = "No Drink"
  94.   end if
  95.   setRecipeDrinkName(slotNum, drinkName, 0)
  96.   setRecipeFullText(slotNum, fullText, 0)
  97.   setRecipePatronName(slotNum, currentName(), 0)
  98. end
  99.  
  100. on setRecipeFullText patronNum, newText
  101.   global gRecipeWindow
  102.   memName = "curRecipeQuantities" & patronNum
  103.   setRecipeText(memName, newText, noRecipeText(patronNum), 1)
  104. end
  105.  
  106. on setRecipeQuickText barSlot, newQuickText
  107.   if barSlot = findActiveRecipeSlot() then
  108.     setRecipeText("QuickRecipe", newQuickText, member("QuickRecipe").text, 1)
  109.   end if
  110. end
  111.  
  112. on noRecipeText patronNum, quickFlag
  113.   global gBarTopManager
  114.   if quickFlag then
  115.     return "The customer has not ordered a drink yet."
  116.   else
  117.     if voidp(gBarTopManager) then
  118.       return "No recipe available"
  119.     else
  120.       if inRecipeMode() then
  121.         return "The customer has not ordered a drink yet." & RETURN & RETURN & "After checking the customer's ID, click the Take Order button at the bottom of the screen to take the customer's order, which will appear in place of this text. In Recipe Practice Mode, you'll choose the recipe from the alphabetical list under the red 'A-Z' tab. In the normal game play mode, use the Take Order button to take the customer's order."
  122.       else
  123.         if gBarTopManager.pBarSpots[patronNum][#charCode] = #none then
  124.           return "There is no customer standing at the bar in position" && patronNum & ". Switch to another customer by clicking on the customer's name in the upper right of this window or using the 1, 2, 3, or Tab keys on the keyboard."
  125.         else
  126.           return "The customer has not ordered a drink yet." & RETURN & RETURN & "After checking the customer's ID, click the Take Order button at the bottom of the screen to take the customer's order, which will appear in place of this text. Use the Exit button at the upper right of this Recipe Book window to close it. Use the Recipe Book icon at the bottom of the screen to re-open the Recipe Book to this page."
  127.         end if
  128.       end if
  129.     end if
  130.   end if
  131. end
  132.  
  133. on refreshHelpItem itemCode
  134.   global gScroller, gLastLabel, gPlayerTipsThisLevel
  135.   if gLastLabel <> "Help2" then
  136.     exit
  137.   end if
  138.   newName = getname(itemCode)
  139.   newText = getHelpDesc(itemCode)
  140.   if itemCode = #tipregister then
  141.     newText = "The tip register displays your cumulative tip earnings. You will earn larger tips by taking customers' orders and mixing their drinks in a timely fashion, using the correct ingredients in the proper amounts, and giving out drink tickets."
  142.     newText = newText & RETURN & RETURN & "Tips earned this shift:                 " && "$" && string(gPlayerTipsThisLevel) & RETURN
  143.     if inRecipeMode() then
  144.     else
  145.       newText = newText & "Minimum tips needed to advance:" && "$" && currentLevel(#MINTIPS) & RETURN
  146.       newText = newText & "Advance early if you earn:           " && "$" && currentLevel(#MAXEARLYTIPS)
  147.     end if
  148.   else
  149.     if itemCode = #progmeter then
  150.       if inRecipeMode() then
  151.         maxTime = "No limit"
  152.         timeLeft = "No limit"
  153.       else
  154.         maxTime = displayTimeUnits(maxTimeOnThisLevel())
  155.         timeLeft = displayTimeUnits(timeLeftOnThisLevel())
  156.       end if
  157.       newText = newText & RETURN & RETURN & "Max time on this level:       " && maxTime & RETURN
  158.       newText = newText & "Elapsed time on this level: " && displayTimeUnits(timeOnThisLevel()) & RETURN
  159.       newText = newText & "Time left on this level:        " & timeLeft
  160.     end if
  161.   end if
  162.   if not voidp(newName) then
  163.     sendSprite(gScroller.spriteNum - 1, #mRefresh, newName)
  164.   end if
  165.   if not voidp(newText) then
  166.     sendSprite(gScroller.spriteNum, #mRefresh, newText)
  167.   end if
  168.   if the number of member ("hpg_" & itemCode) > 1 then
  169.     newPict = member("hpg_" & itemCode)
  170.   else
  171.     if isSodaIngredient(itemCode) then
  172.       newPict = member("hpg_sodagun")
  173.     else
  174.       if isXbottleIngredient(itemCode) or (itemCode = #other) then
  175.         newPict = member("hpg_xbottle")
  176.       else
  177.         newPict = VOID
  178.       end if
  179.     end if
  180.   end if
  181.   if not voidp(newPict) then
  182.     sendSprite(gScroller.spriteNum - 2, #mRefresh, newPict)
  183.   end if
  184.   updateStage()
  185. end
  186.  
  187. on customHelpTopic helpTopic, dontForce
  188.   global gUserTips, gHelpTopicNumber
  189.   lastHelpTopic = gHelpTopicNumber
  190.   if integerp(helpTopic) then
  191.     if helpTopic > count(gUserTips) then
  192.       return 0
  193.     end if
  194.   end if
  195.   case helpTopic of
  196.     #X, #Xbottle:
  197.       gHelpTopicNumber = 1
  198.     #Soda, #sodagun:
  199.       gHelpTopicNumber = 2
  200.     #Twist:
  201.       gHelpTopicNumber = 3
  202.     #coatandrim:
  203.       gHelpTopicNumber = 4
  204.     otherwise:
  205.       gHelpTopicNumber = helpTopic
  206.   end case
  207.   if dontForce and (gHelpTopicNumber = lastHelpTopic) then
  208.     return 0
  209.   end if
  210.   if (gHelpTopicNumber < 0) or (gHelpTopicNumber > count(gUserTips)) then
  211.     return 0
  212.   end if
  213.   newName = replaceAltOption(gUserTips[gHelpTopicNumber][#tipName])
  214.   newHelp = replaceAltOption(gUserTips[gHelpTopicNumber][#tipText])
  215.   customHelpItem(newName, newHelp)
  216.   return 1
  217. end
  218.  
  219. on customHelpItem newName, newText
  220.   global gScroller, gLastLabel
  221.   goToLabel("Help")
  222.   if not voidp(newName) then
  223.     sendSprite(gScroller.spriteNum - 1, #mRefresh, newName)
  224.   end if
  225.   if not voidp(newText) then
  226.     sendSprite(gScroller.spriteNum, #mRefresh, newText)
  227.   end if
  228.   sendSprite(gScroller.spriteNum - 2, #mRefresh, member("hpg_xbottle"))
  229.   updateStage()
  230. end
  231.  
  232. on recipeWindowLabel
  233.   global gLastLabel
  234.   return gLastLabel
  235. end
  236.  
  237. on goToLabel dest
  238.   global gLastLabel
  239.   if not (integerp(dest) or (label(dest) > 0)) then
  240.     exit
  241.   end if
  242.   pageSound()
  243.   if dest = "QuickView" then
  244.   else
  245.     fullSize()
  246.   end if
  247.   gLastLabel = dest
  248.   if (label(dest) > 0) or integerp(dest) then
  249.     go(dest)
  250.   end if
  251. end
  252.  
  253. on quickView
  254.   global gQuickWidth, gLastCurrent
  255.   if not isVisible(the activeWindow) then
  256.     exit
  257.   end if
  258.   gLastCurrent = findActiveRecipeSlot()
  259.   slotNum = gLastCurrent
  260.   recipeID = currentRecipe()
  261.   if recipeID > 0 then
  262.     recipeInfo = createRecipe(recipeID)
  263.     quickText = recipeInfo[#quickView]
  264.     recipeName = recipeInfo[#name]
  265.   else
  266.     quickText = noRecipeText(slotNum, 1)
  267.     recipeName = "No Drink"
  268.   end if
  269.   setRecipeDrinkName(slotNum, recipeName, 0)
  270.   setRecipeQuickText(slotNum, quickText, 0)
  271.   setRecipePatronName(slotNum, currentName(), 0)
  272.   quickHeight = 80 + member("QuickRecipe").rect.height
  273.   adjustWindowWidth((the activeWindow).rect.width - gQuickWidth, (the activeWindow).rect.height - quickHeight)
  274. end
  275.  
  276. on helpUserWithThisIngredient pSpr, rawIngredients
  277.   global gToolTip
  278.   if paused() then
  279.     exit
  280.   end if
  281.   ingredients = []
  282.   repeat with X = 1 to count(rawIngredients)
  283.     thisIng = findingredientbyid(rawIngredients[X][#INGID])
  284.     cat = getCategory(thisIng)
  285.     if (cat >= 2) and (cat <= 9) then
  286.       add(ingredients, thisIng)
  287.     end if
  288.   end repeat
  289.   X = PointToLine(pSpr, the mouseLoc)
  290.   if (X > 0) and (X <= count(ingredients)) then
  291.     ingredient = ingredients[X]
  292.     return [X, ingredient]
  293.   else
  294.     return [0, VOID]
  295.   end if
  296. end
  297.